
var ctx = ctx;
$(function(){
   /* var val=$('input:radio[name="wardPatient"]:checked').val();
    funItem(val);*/


    /*身份证号回车事件，验证身份证所属人是否是待入科*/
    $("#idNo").keydown(function(e){
        var idNo = $("#idNo").val();
        var bedId = $("#bedId").val();
        if (e.keyCode == 13) {
            validIdCard(idNo,bedId);
            return false;
        }
    });
});

//选中单选按钮，更改radio选中值
function changeRadios(obj,bedId) {
    $('input:radio[value='+obj+']').prop("checked",true);
    funItem(obj,bedId);
}
//病人列表切换
function funItem(obj,bedId) {
    if (obj == '1') {
        $("#nurse_waitNewInPatientList").show();
        $("#nurse_waitTurnInPatientList").hide();
        loadDiv('nurse_waitNewInPatientList',ctx+'/nurse/wardCirculation/waitWardPatientList?bedRecId='+bedId);
    } else {
        $("#nurse_waitNewInPatientList").hide();
        $("#nurse_waitTurnInPatientList").show();
        loadDiv('nurse_waitTurnInPatientList',ctx+'/nurse/wardCirculation/allWaitWardPatientList?bedRecId='+bedId);
    }
}

function validIdCard(idNo,bedId){
    $.ajax({
        type: 'POST',
        url: ctx + '/nurse/wardCirculation/validIdCard?idNo='+idNo,
        contentType: 'application/json',
        dataType: 'json',
        success: function (data) {
            if (data.code=="success") {
                loadDiv('nurse_turnInPatient',ctx+'/nurse/wardCirculation/findInfoByParam?idNo='+idNo+"&bedRecId="+bedId);
            } else{
                toastr.info('该病人已入病区或者不存在');
                return;
            }
        },error: function (data) {
            toastr.error('网络连接失败！');
            return;
        }
    });
}

function formSaveTurnInLoad(divId,formId,url,hrefUrl){
   var bedNo = $("#bedNo").val();
   if(bedNo!=null&&bedNo!=''){
       if(flag){
           if ($('#' + formId).parsley().validate()) {
               flag=false;
               $("#"+formId+" input,#"+formId+" select").removeAttr("disabled");
               $.ajax({
                   type: "POST",
                   data:$("#"+formId).serialize(),
                   url: url,
                   dataType: "json",
                   success: function(data) {
                       if (data.code == "success") {
                           toastr.success(data.data);
                           parent.layer.closeAll(); //关闭当前弹层
                           // loadDiv(divId,hrefUrl);
                           parent.refesh();
                       }else {
                           flag=true;
                           toastr.error(data.data);
                       }
                   },
                   error: function(data) {
                       toastr.error('网络连接错误,请检查网络');
                       flag=true;
                   }
               });
           }
       }
       return false;
   }else{
       toastr.info('请选择要移入病人床位信息');
       return false;
   }

}




